#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
const int INF = 0x3f3f3f3f;
int A[maxn], B[maxn], le[maxn], g[maxn];
int bg[maxn];
int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int t, n = 0;
    while(cin >> t) A[++n] = t;
//    reverse(A+1, A+1+n);
    memset(le, -1, sizeof(le));
    memset(g, INF, sizeof(g));
    int lemax = 0, gmax = 0;
    for (int i = 1; i <=n ; ++i) {
        int k = upper_bound(le+1, le+1+n, A[i], greater<>()) - le;
        lemax = max(lemax, k);
        le[k] = A[i];

        k = lower_bound(g+1, g+1+n, A[i]) - g;
        gmax = max(gmax, k);
        g[k] = A[i];
    }

    cout << lemax << "\n" << gmax;
    return 0;
}